package com.wjh.kt_live.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.wjh.kt_live.service.LiveCourseService;
import com.wjh.kt_vod.model.live.LiveCourse;
import com.wjh.kt_vod.result.Result;
import com.wjh.kt_vod.vo.live.LiveCourseFormVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 直播课程表 前端控制器
 * </p>
 *
 * @author Wang_Junhong
 * @since 2022-07-20 05:48:33
 */

@Api(tags = "直播管理")
@RestController
@RequestMapping("/admin/live/liveCourse")
public class LiveCourseController {


    @Autowired
    private LiveCourseService liveCourseService;

    @ApiOperation(value = "删除直播")
    @DeleteMapping("/remove/{id}")
    public Result remove(@PathVariable("id") Long id){
        liveCourseService.removeLive(id);
        return Result.ok();
    }

    @ApiOperation(value = "添加直播")
    @PostMapping("/save")
    public Result save(@RequestBody LiveCourseFormVo liveCourseFormVo){
        liveCourseService.saveLive(liveCourseFormVo);
        return Result.ok();

    }


    @ApiOperation(value = "直播课程表")
    @GetMapping("/{page}/{limit}")
    public Result list(@PathVariable("page") Long page,
                       @PathVariable("limit") Long limit){

        Page<LiveCourse> liveCoursePage = new Page<>(page,limit);
        IPage<LiveCourse> liveCourseIPage = liveCourseService.selectPage(liveCoursePage);
        return Result.ok(liveCourseIPage) ;

    }




}
